﻿using Microsoft.Extensions.Logging;
using System.Text.Json;
using System.Threading.Tasks;

namespace TK.Socket.ServerDemo
{
    /// <summary>
    /// 接收处理程序
    /// </summary>
    public class MyReceiveHandler : IReceiveDataHandler
    {
        readonly ILogger<MyReceiveHandler> _logger;

        public MyReceiveHandler(ILogger<MyReceiveHandler> logger)
        {
            _logger = logger;
        }

        public Task ReceiveData(DataPacket data)
        {
            var msg = JsonSerializer.Serialize(data);
            _logger.LogInformation(msg);
            return Task.CompletedTask;
        }
    }
}
